<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link rel="stylesheet" type="text/css" href="./styles1/tabber.css">
<script type="text/javascript" src="./js/tabber.js"></script>

    <?php
    include 'header.php';
    ?>

<?php
$username = "fossilplot";
$password = "fossilplot";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");


//select a database to work with
$selected = mysql_select_db("fossilplot",$dbhandle)
  or die("Could not select examples");

$debug=0;
$fad=$_POST['fad'];
$lad=$_POST['lad'];

$d=$_POST['diversity'];
$o=$_POST['Origination'];
$e=$_POST['Extinction'];
$radio_d=$_POST['Div1'];

$radio_o=$_POST['Ori1'];

$radio_e=$_POST['Ex1'];

$arrfad=explode(',',$fad);
$arrlad=explode(',',$lad);

//echo "fad is $fad<br><br>";
//echo "lad is $lad<br><br>";

//echo "d is $d"."<br>";
//echo "o is $o"."<br>";
//echo "e is $e"."<br>";

//echo "radio_d is $radio_d"."<br>";
//echo "radio_o is $radio_o"."<br>";
//echo "radio_e is $radio_e"."<br>";


//for ($i=0; $i<sizeof($arrfad);$i++){
 // echo $arrfad[$i]."<br>";

//}


$result_stgintv=mysql_query("select * from stgintv") or die ("error selecting from stgintv!!");
for($tmp=0; $tmp<mysql_num_rows($result_stgintv); $tmp++ ){
  $arr[$tmp]=0; //it is for origination
  $arrdvt[$tmp] =0;
  $arrext[$tmp]=0;
 }
 
 for ($i=0; $i<sizeof($arrfad);$i++){
    while($row_stgintv=mysql_fetch_array($result_stgintv)){
      if ($row_stgintv{'end'}<=$arrfad[$i] && $arrfad[$i]<= $row_stgintv{'begin'}){ //this if for origination
          $arr[$row_stgintv{'id'}]+=1;
         // break;
      }
      
      if($arrlad[$i] <= $row_stgintv{'begin'} && $arrlad[$i] >= $row_stgintv{'end'}){
        $arrext[$row_stgintv{'id'}] += 1;
      }
      
      if($arrfad[$i] <= $row_stgintv{'begin'} && $arrlad[$i] >= $row_stgintv{'end'}){
        $arrdvt[$row_stgintv{'id'}] += 1;
        //break;
      }
      else if($arrfad[$i] <= $row_stgintv{'begin'} && $arrfad[$i] >= $row_stgintv{'end'}){
        $arrdvt[$row_stgintv{'id'}] += 1;
        //break;
      }
      else if($arrlad[$i] <= $row_stgintv{'begin'} && $arrlad[$i] >= $row_stgintv{'end'}){
        $arrdvt[$row_stgintv{'id'}] += 1;
        //break;
      }
      else if($arrfad[$i] >= $row_stgintv{'begin'} && $arrlad[$i] <= $row_stgintv{'end'}){
        $arrdvt[$row_stgintv{'id'}] += 1;
        //break;
      }
      
      
  
  
    } 
    $result_stgintv=mysql_query("select * from stgintv") or die ("error!!"); 
 }
 
 
 if($debug){
 $total=0;
 for($tmp=0; $tmp<mysql_num_rows($result_stgintv); $tmp++ ){
  print "arr is ".$arr[$tmp]."<br>";
   $total = $total+ $arr[$tmp];
 }
 echo "total is ".$total;
 
 } //debug
 
 
 if($o=="on"){ 
  $File = "../../../admin1/list/graph/write.php";
  $Handle = fopen($File, 'w');
  if($radio_o=="Rate2"){
    $Data = "<?php
    include (\"./src/jpgraph.php\");
    include (\"./src/jpgraph_line.php\");
    \$datay=array";
    fwrite($Handle, $Data);
    $barval="($arr[0]";
    for($tmp=1; $tmp<sizeof($arr); $tmp++){
      $rate=($arr[$tmp]/sizeof($arrfad))*100;
      $barval =$barval.",".$rate;
    }
    $barval=$barval.")";
	$rateo=$barval;
    if($debug) {echo "barvalue is".$barval;}
    $Data="$barval;
    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);
    \$graph->img->SetMargin(40,30,20,80);
    \$lineplot = new LinePlot(\$datay);
    
    
    \$lineplot->mark->SetType(MARK_UTRIANGLE);
    
    \$lineplot->value->Show();
    \$graph->Add(\$lineplot);
    \$graph->title->Set(\"Rate of Origination\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    
    \$lineplot->SetColor(\"green\");
    \$lineplot->SetWeight(2);
    \$lineplot->value->SetColor(\"green\"); 
    
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";

    
  } // end of if radio_o=Rate2
  else{
    $Data = "<?php
    include (\"./src/jpgraph.php\");
    include (\"./src/jpgraph_bar.php\");
    \$datay=array";
    fwrite($Handle, $Data);
    $barval="($arr[0]";
    for($tmp=1; $tmp<sizeof($arr); $tmp++){    
      $barval =$barval.",".$arr[$tmp];
    }
    $barval=$barval.")";
    if($debug) {echo "barvalue is".$barval;}
    $Data="$barval;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();
    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$bplot = new BarPlot(\$datay);
    \$bplot->SetFillColor('green');
    \$bplot->value->Show();
    \$graph->Add(\$bplot);
    \$graph->title->Set(\"Origination\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";  
  
  }
  
  
   fwrite($Handle, $Data);
   fclose($Handle);
  //unlink the old graph
  $myFile = "../../../admin1/list/graph/jpgraph_cache/write.png";
  unlink($myFile);


  //echo "<img src=\"http://localhost/test/admin1/list/graph/write.php\">";
  
  } //end of if($o is on)
  
  
  
if($d=="on"){
 
 
 $File = "../../../admin1/list/graph/writedvt.php";
 $Handle = fopen($File, 'w');
 if($radio_d =="rate"){
  $Data = "<?php
  include (\"./src/jpgraph.php\");
  include (\"./src/jpgraph_line.php\");
  \$datay=array";
  fwrite($Handle, $Data);
  $barval="($arrdvt[0]";
  
  $total=0;
  for($tmp=1; $tmp<sizeof($arrdvt); $tmp++){
      $total += $arrdvt[$tmp];
  }  
  for($tmp=1; $tmp<sizeof($arrdvt); $tmp++){
    $rate=($arrdvt[$tmp]/$total)*100;
    $barval =$barval.",".$rate;
  }
  $barval=$barval.")";
	$rated=$barval;
  if($debug) {echo "barvalue is".$barval;}

  $Data="$barval;

  \$graph = new Graph(800,450,\"auto\");    
  \$graph->SetScale(\"textlin\");
  \$graph->SetShadow();

  \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
  \$graph->xaxis->SetTickLabels(\$datax);
  \$graph->xaxis->SetLabelAngle(90);

  \$graph->img->SetMargin(40,30,20,80);
  \$lineplot = new LinePlot(\$datay);
  \$lineplot->mark->SetType(MARK_UTRIANGLE);
  \$lineplot->value->Show();
  \$graph->Add(\$lineplot);
  \$graph->title->Set(\"Rate of Diversity\");
  \$graph->xaxis->title->Set(\"Stage Interval\");
  \$graph->xaxis->title->SetMargin(40);
  \$graph->yaxis->title->Set(\"Number of Genera\");
  
  \$lineplot->SetColor(\"blue\");
  \$lineplot->SetWeight(2);
  \$lineplot->value->SetColor(\"blue\");
  \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
  \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
  \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
  \$graph->Stroke();
  ?>";
  }//end of if(radio_d==on)
  else{
    $Data = "<?php
    include (\"./src/jpgraph.php\");
    include (\"./src/jpgraph_bar.php\");
    \$datay=array";
    fwrite($Handle, $Data);

    $barval="($arrdvt[0]"; 
 
    for($tmp=1; $tmp<sizeof($arrdvt); $tmp++){
      
      $barval =$barval.",".$arrdvt[$tmp];
    }

    $barval=$barval.")";

    if($debug) {echo "barvalue is".$barval;}

    $Data="$barval;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$bplot = new BarPlot(\$datay);
    \$bplot->SetFillColor('blue');
    \$bplot->value->Show();
    \$graph->Add(\$bplot);
    \$graph->title->Set(\"Generic Diversity\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>"; 
  
  }

  fwrite($Handle, $Data);
  fclose($Handle);

  //unlink the old graph
  
  $myFile = "../../../admin1/list/graph/jpgraph_cache/writedvt.png";
  unlink($myFile);


  //echo "<img src=\"http://localhost/test/admin1/list/graph/writedvt.php\">";
  
  } //end of if($d is on)
  
  
  
  
  
  if($e=="on"){ 
    $File = "../../../admin1/list/graph/writeext.php";
    $Handle = fopen($File, 'w');
    if($radio_e =="Rate3"){
      $Data = "<?php
      include (\"./src/jpgraph.php\");
      include (\"./src/jpgraph_line.php\");
      \$datay=array";
      fwrite($Handle, $Data);

      $barval="($arrext[0]";
      $total=0;
      for($tmp=1; $tmp<sizeof($arrext); $tmp++){
          $total += $arrext[$tmp];  
      }
      for($tmp=1; $tmp<sizeof($arrext); $tmp++){
        $rate=($arrext[$tmp]/$total)*100;
        $barval =$barval.",".$rate;
      } 

    $barval=$barval.")";
	$ratee=$barval;
    if($debug) {echo "barvalue is".$barval;}

    $Data="$barval;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$lineplot = new LinePlot(\$datay);

    \$lineplot->mark->SetType(MARK_UTRIANGLE);
    \$lineplot->value->Show();
    \$graph->Add(\$lineplot);
    \$graph->title->Set(\"Rate of Extinction\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$lineplot->SetColor(\"orange\");
    \$lineplot->SetWeight(2);
    \$lineplot->value->SetColor(\"orange\");
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";
   }
   else{
    $Data = "<?php
    include (\"./src/jpgraph.php\");
    include (\"./src/jpgraph_bar.php\");
    \$datay=array";
    fwrite($Handle, $Data);

    $barval="($arrext[0]";
 
    for($tmp=1; $tmp<sizeof($arrext); $tmp++){
      
      $barval =$barval.",".$arrext[$tmp];
    }

    $barval=$barval.")";

    if($debug) {echo "barvalue is".$barval;}

    $Data="$barval;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$bplot = new BarPlot(\$datay);
    \$bplot->SetFillColor('orange');
    \$bplot->value->Show();
    \$graph->Add(\$bplot);
    \$graph->title->Set(\"Extinction\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";  
   
   }

  fwrite($Handle, $Data);
  fclose($Handle);

  //unlink the old graph
    
  $myFile = "../../../admin1/list/graph/jpgraph_cache/writeext.png";
  unlink($myFile);


 // echo "<img src=\"http://localhost/test/admin1/list/graph/writeext.php\">";
  
  } //end of if($e is on)
  
  
  if(($radio_d=="rate" && $d=="on") && ($radio_o=="Rate2" && $o=="on") && ($radio_e=="Rate3" && $e=="on")){
	$File = "../../../admin1/list/graph/comb_dox.php";
    $Handle = fopen($File, 'w');
	$Data = "<?php
      include (\"./src/jpgraph.php\");
      include (\"./src/jpgraph_line.php\");
	  \$datay=array$rated;
	  \$datay2=array$rateo;
	  \$datay3=array$ratee;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$lineplot = new LinePlot(\$datay);
	\$lineplot2 = new LinePlot(\$datay2);
	\$lineplot3 = new LinePlot(\$datay3);

    \$lineplot->mark->SetType(MARK_UTRIANGLE);
    \$lineplot->value->Show();
	
	\$lineplot2->mark->SetType(MARK_UTRIANGLE);
    \$lineplot2->value->Show();
	
	\$lineplot3->mark->SetType(MARK_UTRIANGLE);
    \$lineplot3->value->Show();
	
	
    \$graph->Add(\$lineplot);
	\$graph->Add(\$lineplot2);
	\$graph->Add(\$lineplot3);
    \$graph->title->Set(\"Rate of DOX\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$lineplot->SetColor(\"blue\");
    \$lineplot->SetWeight(2);
    \$lineplot->value->SetColor(\"blue\");
	
	\$lineplot2->SetColor(\"green\");
    \$lineplot2->SetWeight(2);
    \$lineplot2->value->SetColor(\"green\");
	
	\$lineplot3->SetColor(\"orange\");
    \$lineplot3->SetWeight(2);
    \$lineplot3->value->SetColor(\"orange\");
	
	
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";
	fwrite($Handle, $Data);
  fclose($Handle);
  $myFile = "../../../admin1/list/graph/jpgraph_cache/comb_dox.png";
  unlink($myFile);
  
  }
  
  else if(($radio_d=="rate" && $d=="on") && ($radio_o=="Rate2" && $o=="on")){
	$File = "../../../admin1/list/graph/comb_dox.php";
    $Handle = fopen($File, 'w');
	$Data = "<?php
      include (\"./src/jpgraph.php\");
      include (\"./src/jpgraph_line.php\");
	  \$datay=array$rated;
	  \$datay2=array$rateo;
	  

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$lineplot = new LinePlot(\$datay);
	\$lineplot2 = new LinePlot(\$datay2);
	

    \$lineplot->mark->SetType(MARK_UTRIANGLE);
    \$lineplot->value->Show();
	
	\$lineplot2->mark->SetType(MARK_UTRIANGLE);
    \$lineplot2->value->Show();
	
	
	
	
    \$graph->Add(\$lineplot);
	\$graph->Add(\$lineplot2);
	
    \$graph->title->Set(\"Rate of Diversity & Origination\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$lineplot->SetColor(\"blue\");
    \$lineplot->SetWeight(2);
    \$lineplot->value->SetColor(\"blue\");
	
	\$lineplot2->SetColor(\"green\");
    \$lineplot2->SetWeight(2);
    \$lineplot2->value->SetColor(\"green\");
	
		
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";
	fwrite($Handle, $Data);
	fclose($Handle);  
	$myFile = "../../../admin1/list/graph/jpgraph_cache/comb_dox.png";
  unlink($myFile);
  
  }
  
  
  
  else if(($radio_d=="rate" && $d=="on") && ($radio_e=="Rate3" && $e=="on")){
  
  
	$File = "../../../admin1/list/graph/comb_dox.php";
    $Handle = fopen($File, 'w');
	$Data = "<?php
      include (\"./src/jpgraph.php\");
      include (\"./src/jpgraph_line.php\");
	  \$datay=array$rated;
	  
	  \$datay3=array$ratee;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    \$lineplot = new LinePlot(\$datay);
	
	\$lineplot3 = new LinePlot(\$datay3);

    \$lineplot->mark->SetType(MARK_UTRIANGLE);
    \$lineplot->value->Show();
	
	
	
	\$lineplot3->mark->SetType(MARK_UTRIANGLE);
    \$lineplot3->value->Show();
	
	
    \$graph->Add(\$lineplot);
	
	\$graph->Add(\$lineplot3);
    \$graph->title->Set(\"Rate of Diversity & Extinction\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    \$lineplot->SetColor(\"blue\");
    \$lineplot->SetWeight(2);
    \$lineplot->value->SetColor(\"blue\");
	
	
	
	\$lineplot3->SetColor(\"orange\");
    \$lineplot3->SetWeight(2);
    \$lineplot3->value->SetColor(\"orange\");
	
	
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";
	fwrite($Handle, $Data);
  fclose($Handle);
  $myFile = "../../../admin1/list/graph/jpgraph_cache/comb_dox.png";
  unlink($myFile);
  
  }
  
  
  else if(($radio_o=="Rate2" && $o=="on") && ($radio_e=="Rate3" && $e=="on")){
	$File = "../../../admin1/list/graph/comb_dox.php";
    $Handle = fopen($File, 'w');
	$Data = "<?php
      include (\"./src/jpgraph.php\");
      include (\"./src/jpgraph_line.php\");
	  
	  \$datay2=array$rateo;
	  \$datay3=array$ratee;

    \$graph = new Graph(800,450,\"auto\");    
    \$graph->SetScale(\"textlin\");
    \$graph->SetShadow();

    \$datax = array(\"V\",\"Cm(l)\",\"Cm(m)\",\"Cm(u)\",\"O(l)\",\"O(m)\",\"O(u)\",\"S(l)\",\"S(m)\",\"S(u)\",\"D(l)\",\"D(m)\",\"D(u)\",\"CMs\",\"CPn\",\"P(l)\",\"P(u)\",\"Tr(l)\",\"Tr(m)\",\"Tr(u)\",\"J(l)\",\"J(m)\",\"J(u)\",\"K(l)\",\"K(u)\",\"Pg(Pal)\",\"Pg(Eo)\",\"Pg(Oli)\",\"Ng(Mio)\",\"Ng(Pli)\",\"Ng(Plei)\",\"Ng(Re)\");
    \$graph->xaxis->SetTickLabels(\$datax);
    \$graph->xaxis->SetLabelAngle(90);

    \$graph->img->SetMargin(40,30,20,80);
    
	\$lineplot2 = new LinePlot(\$datay2);
	\$lineplot3 = new LinePlot(\$datay3);

    
	
	\$lineplot2->mark->SetType(MARK_UTRIANGLE);
    \$lineplot2->value->Show();
	
	\$lineplot3->mark->SetType(MARK_UTRIANGLE);
    \$lineplot3->value->Show();
	
	
    
	\$graph->Add(\$lineplot2);
	\$graph->Add(\$lineplot3);
    \$graph->title->Set(\"Rate of Origination & Extinction\");
    \$graph->xaxis->title->Set(\"Stage Interval\");
    \$graph->xaxis->title->SetMargin(40);
    \$graph->yaxis->title->Set(\"Number of Genera\");
    
	
	\$lineplot2->SetColor(\"green\");
    \$lineplot2->SetWeight(2);
    \$lineplot2->value->SetColor(\"green\");
	
	\$lineplot3->SetColor(\"orange\");
    \$lineplot3->SetWeight(2);
    \$lineplot3->value->SetColor(\"orange\");
	
	
    \$graph->title->SetFont(FF_FONT1,FS_BOLD,8);
    \$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
    \$graph->Stroke();
    ?>";
	fwrite($Handle, $Data);
  fclose($Handle);
  $myFile = "../../../admin1/list/graph/jpgraph_cache/comb_dox.png";
  unlink($myFile);
  
  }
  
  
  
  $k=0;
  if($radio_o=='Rate2') {$k=$k+1;}
  if($radio_e=='Rate3') {$k=$k+1;}
  if($radio_d=='rate') {$k=$k+1;}  
  //echo "k is $k<br>";
  
  
  if($d== "on"){
    if($o=="on"){
      if($e=="on"){
        echo "<div class=\"tabber\" id=\"tab1\">";          

          echo "<div class=\"tabbertab\" title=\"Diversity\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/writedvt.php\">";
          echo "</div>";
          
          echo "<div class=\"tabbertab\" title=\"Origination\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/write.php\">"; 
          echo "</div>";


          echo "<div class=\"tabbertab\" title=\"Extinction\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/writeext.php\">";
          echo "</div>";
		  if((($radio_d=="rate") && ($radio_o=="Rate2") && ($radio_e=="Rate3"))||(($radio_d=="rate") && ($radio_o=="Rate2")) ||(($radio_o=="Rate2") && ($radio_e=="Rate3")) || (($radio_d=="rate") && ($radio_e=="Rate3"))){
			echo "<div class=\"tabbertab\" title=\"Rate_DOX\">";
			echo "<img src=\"http://localhost/test/admin1/list/graph/comb_dox.php\">";
			echo "</div>";
		  
		  }
        echo "</div>";
      
      }
      else { // e is not on, o and d are on    
        echo "<div class=\"tabber\" id=\"tab1\">";          

          echo "<div class=\"tabbertab\" title=\"Diversity\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/writedvt.php\">";
          echo "</div>";
          
          echo "<div class=\"tabbertab\" title=\"Origination\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/write.php\">"; 
          echo "</div>";
		  
		  if(($radio_d=="rate") && ($radio_o=="Rate2")){
			echo "<div class=\"tabbertab\" title=\"Rate_D.O.\">";
			echo "<img src=\"http://localhost/test/admin1/list/graph/comb_dox.php\">";
			echo "</div>";
		  
		  }
		  
        echo "</div>";      
      }    
    }
    else{ //o is not on, d is on, e is on or not
      if($e=="on"){ //d is on and e is on, o not on
        echo "<div class=\"tabber\" id=\"tab1\">";          

          echo "<div class=\"tabbertab\" title=\"Diversity\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/writedvt.php\">";
          echo "</div>";
          
          echo "<div class=\"tabbertab\" title=\"Extinction\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/writeext.php\">";
          echo "</div>";
		  
		  if(($radio_d=="rate") && ($radio_e=="Rate3")){
			echo "<div class=\"tabbertab\" title=\"Rate_D.X.\">";
			echo "<img src=\"http://localhost/test/admin1/list/graph/comb_dox.php\">";
			echo "</div>";
		  
		  }
		  
		  
        echo "</div>";     
      
      }
      else{ //e and o are not on
        echo "<div class=\"tabber\" id=\"tab1\">";          

          echo "<div class=\"tabbertab\" title=\"Diversity\">";
          echo "<img src=\"http://localhost/test/admin1/list/graph/writedvt.php\">";
          echo "</div>";          
          
        echo "</div>";      
      
      }    
    }// for 'else{ //o is not on, d is on, e is on or not'
  
  }
  else{ //$d is not on
    if($o=="on"){
      if($e=="on"){
          echo "<div class=\"tabber\" id=\"tab1\">";  
            echo "<div class=\"tabbertab\" title=\"Origination\">";
            echo "<img src=\"http://localhost/test/admin1/list/graph/write.php\">"; 
            echo "</div>";  
            echo "<div class=\"tabbertab\" title=\"Extinction\">";
            echo "<img src=\"http://localhost/test/admin1/list/graph/writeext.php\">";
            echo "</div>";
			
			if(($radio_o=="Rate2") && ($radio_e=="Rate3")){
			echo "<div class=\"tabbertab\" title=\"Rate_O.X.\">";
			echo "<img src=\"http://localhost/test/admin1/list/graph/comb_dox.php\">";
			echo "</div>";
		  
		  }
			
			
			
          echo "</div>";
      
      }else{ //only o is on
          echo "<div class=\"tabber\" id=\"tab1\">";  
            echo "<div class=\"tabbertab\" title=\"Origination\">";
            echo "<img src=\"http://localhost/test/admin1/list/graph/write.php\">"; 
            echo "</div>";            
          echo "</div>";
      
      }    
    
    }
    else { // d and o are off
      if ($e =="on"){
        echo "<div class=\"tabber\" id=\"tab1\">";  
            echo "<div class=\"tabbertab\" title=\"Extinction\">";
            echo "<img src=\"http://localhost/test/admin1/list/graph/writeext.php\">";
            echo "</div>";
          echo "</div>";
      
      }
      else{ //d,o,x are off
        echo "please select Diversity, Origination, or Extinction for the graph.";
      
      }
    
    
    }
  
  
  }
  
  
  
  
?>

<?php include 'footer.php';?>
 </body>

</html>